import pymysql
from DBUtils.PooledDB import PooledDB

class myqlPoole:
    def __init__(self,strsql,dbname):
        self.str_sql=strsql
        self.db_name=dbname


    def mysql_query(self):

        pool=PooledDB(pymysql,5,host='localhost',user='root',password='123456',db=self.db_name,port=3306)

        conn=pool.connection()

        cur=conn.cursor()
        r=cur.execute(self.str_sql)
        r=cur.fetchall()
        cur.close()
        conn.close()
        return r

if __name__ == '__main__':
    q = myqlPoole("select * from sc_st_aj s ", "sc_ga_aj")
    for i in q.mysql_query():
        print(i)